/**
 * 
 */
package profile.result;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ductrung.tran
 *
 */
public class StoreResult {

	private String store;
	
	private Map<String, MethodResult> methodResultMap = new HashMap<String, MethodResult>();

	public String getStore() {
		return store;
	}

	public void setStore(String store) {
		this.store = store;
	}

	public Map<String, MethodResult> getMethodResultMap() {
		return methodResultMap;
	}

	public void addMethodResult(MethodResult methodResult) {
		MethodResult existResult = getMethodResult(methodResult.getName());
		if (existResult != null) {
			existResult.merge(methodResult);
		} else {
			this.methodResultMap.put(methodResult.getName(), methodResult);
		}
	}

	public MethodResult getMethodResult(String method) {
		return methodResultMap.get(method);
	}

	public void merge(StoreResult storeResult) {
		for (MethodResult methodResult : storeResult.getMethodResultMap().values()) {
			addMethodResult(methodResult);
		}
	}	
}
